home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 August: Tool Chest / Dev.CD Aug 00 TC Disk 2.toast / pc / sample code / networking / pgpuam / sources / tpgpkey.h < prev    next >
Encoding:
Text File  |  2000-06-23  |  4.0 KB  |  133 lines

  1. //    TPGPkey.h - PGP Key Object  
  2. // 
  3. // Apple Macintosh Developer Technical Support
  4. // Written by:  Vinnie Moscaritolo
  5. //
  6. //  Copyright (work in progress)  Apple Computer, Inc All rights reserved.
  7. //
  8. // You may incorporate this sample code into your applications without
  9. // restriction, though the sample code has been provided "AS IS" and the
  10. // responsibility for its operation is 100% yours.  However, what you are
  11. // not permitted to do is to redistribute the source as "DSC Sample Code"
  12. // after having made changes. If you're going to re-distribute the source,
  13. // we require that you make it clear in the source that the code was
  14. // descended from Apple Sample Code, but that you've made changes.
  15. // 
  16.  
  17. #ifndef _H_TPGPKEY
  18. #define _H_TPGPKEY
  19.  
  20.  
  21. #define PGP_MACINTOSH 1
  22. #include "pgpErrors.h"
  23. #include "pgpKeys.h"
  24. #include "pgpUtilities.h"
  25.  
  26. // ---------------------------------------------------------------------------
  27. //     TPGPkey - PGP Key Object 
  28. // ---------------------------------------------------------------------------
  29. // 
  30. class TPGPkey
  31. {
  32. public:
  33.     //    ENUMS AND TYPEDEFS
  34.     
  35.         enum EKeyIcons{
  36.             kAlertIcon_ID            = 4000, /*129 ?? */
  37.             kIconRSA_ID                = 3000,
  38.             kIconRSA_Revoked_ID        = 3004,
  39.             kIconRSA_Expired_ID        = 3005,
  40.             kIconRSA_Disabled_ID    = 3010,
  41.             kIconDH_ID                = 3007,
  42.             kIconDH_RevokedID        = 3012,
  43.             kIconDH_Expired_ID        = 3013,
  44.             kIconDH_Disabled_ID        = 3006,
  45.             kIcon_KeyNotfound_ID    = 3028
  46.         };
  47.  
  48.  
  49. //     CONSTRUCTORS AND DESTRUCTORS
  50.              TPGPkey()    :
  51.                          fInitialized(false),
  52.                          fKeyRef(kInvalidPGPKeyRef) {};
  53.                          
  54. //     virtual  ~TPGPkey();            
  55.  
  56. // MAIN INTERFACE
  57.     virtual void Initialize(PGPKeyRef);            // initialize
  58.     
  59.  
  60. // ACCESSSORS
  61.     virtual Boolean IsExpired()         { return  fExpired;   };
  62.     virtual Boolean IsRevoked()         { return  fRevoked;   };
  63.     virtual Boolean IsDisabled()         { return  fDisabled;  };
  64.     virtual Boolean IsAxiomatic()         { return  fAxiomatic; };
  65.     virtual Boolean IsOperational()     { return ( PGPContextRefIsValid(fgContext)
  66.                                                 /*    && PGPKeySetRefIsValid(fgPGPKeySetRef)  */
  67.                                                     && PGPKeyRefIsValid(fKeyRef) ); };
  68.                                                     
  69.                                                     
  70.     virtual Boolean CanSign();
  71.     virtual Boolean CanVerify();
  72.                                                     
  73.     virtual Boolean IsInitialized()        { return  fInitialized; };    
  74.  
  75.     virtual PGPPublicKeyAlgorithm GetPublicKeyAlgorithm()    { return  fPublicKeyAlgorithm;   };
  76.     virtual PGPHashAlgorithm      GetHashAlgorithm()         { return  fHashAlgorithm;   };
  77.     virtual    PGPValidity              GetValidity()                { return  fValidity;   };
  78.     virtual PGPInt32              GetTrustLevel()            { return  fTrustLevel; };
  79.     virtual PGPSize                  GetKeySize()                { return  fKeySize; };
  80.     virtual PGPSize                  GetHashSize()                { return  fHashSize; };
  81.     
  82.      
  83.      virtual short    GetIconID();
  84.       virtual long    GetCreateDate()        { return  fCreatedTime;   };
  85.      virtual long    GetExpireDate()        { return  fExpireTime;   };
  86.      
  87.      virtual void    GetFingerprintPString(StringPtr buf);
  88.      virtual void    GetFingerprintBinaryPString (void* outBuf);
  89.      virtual void    GetPrimaryUserNamePString(StringPtr buf);
  90.      virtual void     GetPublicKeyAlgorithmPstring(StringPtr buf);
  91.     virtual void    Export        (void** buf, PGPSize *bufSize );
  92.           
  93.     virtual Boolean    Verify( void* inbuf, PGPSize inBufSize, void* sigbuf,  PGPSize sigBufSize );
  94.     virtual Boolean    Sign( void* inbuf, PGPSize inBufSize, void* sigbuf,  PGPSize *sigBufSize,const char *passPhrase);
  95.     
  96.  
  97.      PGPKeyRef        fKeyRef;            // 
  98.      
  99. // PRIVATE FIELDS
  100. protected:
  101.      Boolean            fInitialized;    
  102.      Boolean            fExpired;
  103.      Boolean            fRevoked;
  104.      Boolean            fDisabled;
  105.      Boolean            fAxiomatic;
  106.     PGPValidity        fValidity;
  107.     PGPInt32        fTrustLevel;
  108.      long             fCreatedTime;
  109.      long             fExpireTime;
  110.      
  111.  
  112.      PGPPublicKeyAlgorithm fPublicKeyAlgorithm;
  113.     PGPHashAlgorithm      fHashAlgorithm;
  114.     PGPSize               fKeySize;
  115.     PGPSize                    fHashSize;
  116.     
  117. // CLASS VARIABLES
  118.  public:
  119.      static     PGPContextRef    fgContext;         
  120.      static     PGPKeySetRef     fgPGPKeySetRef;
  121.      
  122. // CLASS FUNCTIONS
  123. public:
  124.     static     void    Initialize ();
  125.     static     void    Initialize (PGPMemoryMgrRef memMgr);
  126.     static    void    Finalize(); 
  127.     static    void    OpenKeyDefaultRing();
  128.     static  void     CloseKeyRing();
  129.  
  130. };
  131.  
  132. #endif
  133.